using DataDynamics.ActiveReports;
using DataDynamics.ActiveReports.Export.Xls;
using SM.core;
using SS;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
using TVSGPP.func;
namespace TVSBH.func
{
	public class frmBookTemHum1 : Form
	{
		private IContainer components = null;
		private DataGridView dgvProduct;
		private Button btnClose;
		private Button btnSearch;
		private Button btnCreate;
		private Button btnEdit;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label1;
		private DateTimePicker txtfromDay;
		private System.Windows.Forms.Label lblT1;
		private System.Windows.Forms.Label lblT2;
		private System.Windows.Forms.Label lblT3;
		private System.Windows.Forms.Label lblT4;
		private System.Windows.Forms.Label label8;
		private Button btnPrint;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label14;
		private Button btnExportToExcel;
		private Button btnConfig;
		private System.Windows.Forms.Label label13;
		private DataGridViewTextBoxColumn Day;
		private DataGridViewTextBoxColumn Tmp1;
		private DataGridViewTextBoxColumn Tmp2;
		private DataGridViewTextBoxColumn Hum1;
		private DataGridViewTextBoxColumn Hum2;
		private DataGridViewTextBoxColumn PersonAction;
		private DataGridViewTextBoxColumn PersonCheck;
		private DataGridViewTextBoxColumn Note;
		private Func objFunc = new Func();
		private DataTable objTable;
		private DataTable objTableBarcode = new DataTable();
		private Bill objBill = new Bill();
		private string sqlCon = "";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle5 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle6 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle7 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle8 = new DataGridViewCellStyle();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmBookTemHum1));
			this.dgvProduct = new DataGridView();
			this.Day = new DataGridViewTextBoxColumn();
			this.Tmp1 = new DataGridViewTextBoxColumn();
			this.Tmp2 = new DataGridViewTextBoxColumn();
			this.Hum1 = new DataGridViewTextBoxColumn();
			this.Hum2 = new DataGridViewTextBoxColumn();
			this.PersonAction = new DataGridViewTextBoxColumn();
			this.PersonCheck = new DataGridViewTextBoxColumn();
			this.Note = new DataGridViewTextBoxColumn();
			this.btnClose = new Button();
			this.btnSearch = new Button();
			this.btnCreate = new Button();
			this.btnEdit = new Button();
			this.label3 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.txtfromDay = new DateTimePicker();
			this.lblT1 = new System.Windows.Forms.Label();
			this.lblT2 = new System.Windows.Forms.Label();
			this.lblT3 = new System.Windows.Forms.Label();
			this.lblT4 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.btnPrint = new Button();
			this.label9 = new System.Windows.Forms.Label();
			this.label10 = new System.Windows.Forms.Label();
			this.label11 = new System.Windows.Forms.Label();
			this.label12 = new System.Windows.Forms.Label();
			this.label14 = new System.Windows.Forms.Label();
			this.btnExportToExcel = new Button();
			this.btnConfig = new Button();
			this.label13 = new System.Windows.Forms.Label();
			((ISupportInitialize)this.dgvProduct).BeginInit();
			base.SuspendLayout();
			this.dgvProduct.AllowUserToAddRows = false;
			this.dgvProduct.AllowUserToDeleteRows = false;
			this.dgvProduct.AllowUserToOrderColumns = true;
			this.dgvProduct.AllowUserToResizeColumns = false;
			this.dgvProduct.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvProduct.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvProduct.BackgroundColor = Color.White;
			this.dgvProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvProduct.ColumnHeadersVisible = false;
			this.dgvProduct.Columns.AddRange(new DataGridViewColumn[]
			{
				this.Day,
				this.Tmp1,
				this.Tmp2,
				this.Hum1,
				this.Hum2,
				this.PersonAction,
				this.PersonCheck,
				this.Note
			});
			this.dgvProduct.Cursor = Cursors.Hand;
			this.dgvProduct.Location = new System.Drawing.Point(7, 90);
			this.dgvProduct.MultiSelect = false;
			this.dgvProduct.Name = "dgvProduct";
			this.dgvProduct.ReadOnly = true;
			this.dgvProduct.RowHeadersVisible = false;
			this.dgvProduct.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			this.dgvProduct.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvProduct.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvProduct.Size = new Size(886, 470);
			this.dgvProduct.TabIndex = 1;
			this.Day.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Day.DataPropertyName = "Day";
			this.Day.HeaderText = "Ngày";
			this.Day.MinimumWidth = 50;
			this.Day.Name = "Day";
			this.Day.ReadOnly = true;
			this.Day.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.Day.Width = 50;
			this.Tmp1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Tmp1.DataPropertyName = "Tmp1";
			dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleLeft;
			this.Tmp1.DefaultCellStyle = dataGridViewCellStyle2;
			this.Tmp1.HeaderText = "Nhiệt độ";
			this.Tmp1.MinimumWidth = 100;
			this.Tmp1.Name = "Tmp1";
			this.Tmp1.ReadOnly = true;
			this.Tmp1.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.Tmp2.DataPropertyName = "Tmp2";
			dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle3.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle3.ForeColor = Color.Black;
			this.Tmp2.DefaultCellStyle = dataGridViewCellStyle3;
			this.Tmp2.HeaderText = "Nhiệt độ";
			this.Tmp2.MinimumWidth = 100;
			this.Tmp2.Name = "Tmp2";
			this.Tmp2.ReadOnly = true;
			this.Tmp2.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.Hum1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Hum1.DataPropertyName = "Hum1";
			dataGridViewCellStyle4.Alignment = DataGridViewContentAlignment.MiddleLeft;
			this.Hum1.DefaultCellStyle = dataGridViewCellStyle4;
			this.Hum1.HeaderText = "Độ ẩm";
			this.Hum1.MinimumWidth = 100;
			this.Hum1.Name = "Hum1";
			this.Hum1.ReadOnly = true;
			this.Hum1.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.Hum2.DataPropertyName = "Hum2";
			dataGridViewCellStyle5.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle5.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle5.ForeColor = Color.Black;
			this.Hum2.DefaultCellStyle = dataGridViewCellStyle5;
			this.Hum2.HeaderText = "Độ ẩm";
			this.Hum2.MinimumWidth = 100;
			this.Hum2.Name = "Hum2";
			this.Hum2.ReadOnly = true;
			this.Hum2.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.PersonAction.DataPropertyName = "PersonAction";
			dataGridViewCellStyle6.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle6.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			dataGridViewCellStyle6.ForeColor = Color.Black;
			this.PersonAction.DefaultCellStyle = dataGridViewCellStyle6;
			this.PersonAction.HeaderText = "Người thực hiện";
			this.PersonAction.MinimumWidth = 154;
			this.PersonAction.Name = "PersonAction";
			this.PersonAction.ReadOnly = true;
			this.PersonAction.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.PersonAction.Width = 154;
			this.PersonCheck.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.PersonCheck.DataPropertyName = "PersonCheck";
			dataGridViewCellStyle7.Alignment = DataGridViewContentAlignment.MiddleLeft;
			dataGridViewCellStyle7.Font = new Font("Arial", 9.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
			dataGridViewCellStyle7.ForeColor = Color.Black;
			this.PersonCheck.DefaultCellStyle = dataGridViewCellStyle7;
			this.PersonCheck.HeaderText = "Người kiểm tra";
			this.PersonCheck.MinimumWidth = 154;
			this.PersonCheck.Name = "PersonCheck";
			this.PersonCheck.ReadOnly = true;
			this.PersonCheck.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.PersonCheck.Width = 154;
			this.Note.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.Note.DataPropertyName = "Note";
			dataGridViewCellStyle8.Alignment = DataGridViewContentAlignment.MiddleLeft;
			this.Note.DefaultCellStyle = dataGridViewCellStyle8;
			this.Note.HeaderText = "Ghi chú";
			this.Note.Name = "Note";
			this.Note.ReadOnly = true;
			this.Note.SortMode = DataGridViewColumnSortMode.NotSortable;
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnClose.FlatStyle = FlatStyle.Flat;
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new System.Drawing.Point(793, 567);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(100, 26);
			this.btnClose.TabIndex = 38;
			this.btnClose.Text = "Thoát [ ESC ]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.btnSearch.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnSearch.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnSearch.FlatStyle = FlatStyle.Flat;
			this.btnSearch.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSearch.Location = new System.Drawing.Point(79, 567);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new Size(63, 26);
			this.btnSearch.TabIndex = 41;
			this.btnSearch.Text = "Xem sổ";
			this.btnSearch.UseVisualStyleBackColor = true;
			this.btnSearch.Click += new EventHandler(this.btnSearch_Click);
			this.btnCreate.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnCreate.Enabled = false;
			this.btnCreate.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnCreate.FlatStyle = FlatStyle.Flat;
			this.btnCreate.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnCreate.Location = new System.Drawing.Point(245, 567);
			this.btnCreate.Name = "btnCreate";
			this.btnCreate.Size = new Size(123, 26);
			this.btnCreate.TabIndex = 42;
			this.btnCreate.Text = "Lưu thông tin [ F6 ]";
			this.btnCreate.UseVisualStyleBackColor = true;
			this.btnCreate.Click += new EventHandler(this.btnCreate_Click);
			this.btnEdit.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnEdit.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnEdit.FlatStyle = FlatStyle.Flat;
			this.btnEdit.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnEdit.Location = new System.Drawing.Point(144, 567);
			this.btnEdit.Name = "btnEdit";
			this.btnEdit.Size = new Size(99, 26);
			this.btnEdit.TabIndex = 49;
			this.btnEdit.Text = "Cập nhật [ F5 ]";
			this.btnEdit.UseVisualStyleBackColor = true;
			this.btnEdit.Click += new EventHandler(this.btnEdit_Click);
			this.label3.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.label3.AutoSize = true;
			this.label3.Location = new System.Drawing.Point(684, 20);
			this.label3.Name = "label3";
			this.label3.Size = new Size(137, 15);
			this.label3.TabIndex = 57;
			this.label3.Text = "Xem theo Tháng / năm :";
			this.label1.Font = new Font("Arial", 12f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label1.Location = new System.Drawing.Point(7, 13);
			this.label1.Name = "label1";
			this.label1.Size = new Size(690, 26);
			this.label1.TabIndex = 58;
			this.label1.Text = "SỔ THEO DÕI NHIỆT ĐỘ - ĐỘ ẨM CỦA NHÀ THUỐC";
			this.label1.TextAlign = ContentAlignment.MiddleCenter;
			this.txtfromDay.CustomFormat = "MM/yyyy";
			this.txtfromDay.Format = DateTimePickerFormat.Custom;
			this.txtfromDay.Location = new System.Drawing.Point(823, 17);
			this.txtfromDay.Name = "txtfromDay";
			this.txtfromDay.Size = new Size(70, 21);
			this.txtfromDay.TabIndex = 56;
			this.txtfromDay.ValueChanged += new EventHandler(this.txtfromDay_ValueChanged);
			this.lblT1.BorderStyle = BorderStyle.FixedSingle;
			this.lblT1.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.lblT1.Location = new System.Drawing.Point(58, 44);
			this.lblT1.Name = "lblT1";
			this.lblT1.Size = new Size(201, 24);
			this.lblT1.TabIndex = 60;
			this.lblT1.Text = "Nhiệt độ ( Độ C )";
			this.lblT1.TextAlign = ContentAlignment.MiddleCenter;
			this.lblT2.BorderStyle = BorderStyle.FixedSingle;
			this.lblT2.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.lblT2.Location = new System.Drawing.Point(258, 44);
			this.lblT2.Name = "lblT2";
			this.lblT2.Size = new Size(201, 24);
			this.lblT2.TabIndex = 61;
			this.lblT2.Text = "Độ ẩm ( % )";
			this.lblT2.TextAlign = ContentAlignment.MiddleCenter;
			this.lblT3.BorderStyle = BorderStyle.FixedSingle;
			this.lblT3.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.lblT3.Location = new System.Drawing.Point(458, 44);
			this.lblT3.Name = "lblT3";
			this.lblT3.Size = new Size(309, 24);
			this.lblT3.TabIndex = 62;
			this.lblT3.Text = "Ký tên";
			this.lblT3.TextAlign = ContentAlignment.MiddleCenter;
			this.lblT4.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.lblT4.BorderStyle = BorderStyle.FixedSingle;
			this.lblT4.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.lblT4.Location = new System.Drawing.Point(766, 44);
			this.lblT4.Name = "lblT4";
			this.lblT4.Size = new Size(127, 47);
			this.lblT4.TabIndex = 63;
			this.lblT4.Text = "Ghi chú";
			this.lblT4.TextAlign = ContentAlignment.MiddleCenter;
			this.label8.BorderStyle = BorderStyle.FixedSingle;
			this.label8.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label8.Location = new System.Drawing.Point(7, 44);
			this.label8.Name = "label8";
			this.label8.Size = new Size(52, 47);
			this.label8.TabIndex = 64;
			this.label8.Text = "Ngày";
			this.label8.TextAlign = ContentAlignment.MiddleCenter;
			this.btnPrint.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnPrint.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnPrint.FlatStyle = FlatStyle.Flat;
			this.btnPrint.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnPrint.Location = new System.Drawing.Point(370, 567);
			this.btnPrint.Name = "btnPrint";
			this.btnPrint.Size = new Size(105, 26);
			this.btnPrint.TabIndex = 66;
			this.btnPrint.Text = "In báo cáo [ F7 ]";
			this.btnPrint.UseVisualStyleBackColor = true;
			this.btnPrint.Click += new EventHandler(this.btnPrint_Click);
			this.label9.BorderStyle = BorderStyle.FixedSingle;
			this.label9.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label9.Location = new System.Drawing.Point(58, 67);
			this.label9.Name = "label9";
			this.label9.Size = new Size(101, 24);
			this.label9.TabIndex = 67;
			this.label9.Text = "9h";
			this.label9.TextAlign = ContentAlignment.MiddleCenter;
			this.label10.BorderStyle = BorderStyle.FixedSingle;
			this.label10.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label10.Location = new System.Drawing.Point(158, 67);
			this.label10.Name = "label10";
			this.label10.Size = new Size(101, 24);
			this.label10.TabIndex = 68;
			this.label10.Text = "15h";
			this.label10.TextAlign = ContentAlignment.MiddleCenter;
			this.label11.BorderStyle = BorderStyle.FixedSingle;
			this.label11.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label11.Location = new System.Drawing.Point(358, 67);
			this.label11.Name = "label11";
			this.label11.Size = new Size(101, 24);
			this.label11.TabIndex = 70;
			this.label11.Text = "15h";
			this.label11.TextAlign = ContentAlignment.MiddleCenter;
			this.label12.BorderStyle = BorderStyle.FixedSingle;
			this.label12.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label12.Location = new System.Drawing.Point(258, 67);
			this.label12.Name = "label12";
			this.label12.Size = new Size(101, 24);
			this.label12.TabIndex = 69;
			this.label12.Text = "9h";
			this.label12.TextAlign = ContentAlignment.MiddleCenter;
			this.label14.BorderStyle = BorderStyle.FixedSingle;
			this.label14.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label14.Location = new System.Drawing.Point(458, 67);
			this.label14.Name = "label14";
			this.label14.Size = new Size(155, 24);
			this.label14.TabIndex = 71;
			this.label14.Text = "Người thực hiện";
			this.label14.TextAlign = ContentAlignment.MiddleCenter;
			this.btnExportToExcel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnExportToExcel.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnExportToExcel.FlatStyle = FlatStyle.Flat;
			this.btnExportToExcel.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnExportToExcel.Location = new System.Drawing.Point(477, 567);
			this.btnExportToExcel.Name = "btnExportToExcel";
			this.btnExportToExcel.Size = new Size(102, 26);
			this.btnExportToExcel.TabIndex = 75;
			this.btnExportToExcel.Text = "Xuất file Excel";
			this.btnExportToExcel.UseVisualStyleBackColor = true;
			this.btnExportToExcel.Click += new EventHandler(this.btnExportToExcel_Click);
			this.btnConfig.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnConfig.FlatAppearance.BorderColor = Color.FromArgb(255, 128, 255);
			this.btnConfig.FlatStyle = FlatStyle.Flat;
			this.btnConfig.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnConfig.Location = new System.Drawing.Point(7, 567);
			this.btnConfig.Name = "btnConfig";
			this.btnConfig.Size = new Size(70, 26);
			this.btnConfig.TabIndex = 76;
			this.btnConfig.Text = "Cấu hình";
			this.btnConfig.UseVisualStyleBackColor = true;
			this.btnConfig.Click += new EventHandler(this.btnConfig_Click);
			this.label13.BorderStyle = BorderStyle.FixedSingle;
			this.label13.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label13.Location = new System.Drawing.Point(612, 67);
			this.label13.Name = "label13";
			this.label13.Size = new Size(155, 24);
			this.label13.TabIndex = 72;
			this.label13.Text = "Người kiểm tra";
			this.label13.TextAlign = ContentAlignment.MiddleCenter;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.White;
			base.ClientSize = new Size(900, 600);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.btnConfig);
			base.Controls.Add(this.btnExportToExcel);
			base.Controls.Add(this.label13);
			base.Controls.Add(this.label14);
			base.Controls.Add(this.label11);
			base.Controls.Add(this.label12);
			base.Controls.Add(this.label10);
			base.Controls.Add(this.label9);
			base.Controls.Add(this.btnPrint);
			base.Controls.Add(this.label8);
			base.Controls.Add(this.lblT4);
			base.Controls.Add(this.lblT3);
			base.Controls.Add(this.lblT2);
			base.Controls.Add(this.lblT1);
			base.Controls.Add(this.txtfromDay);
			base.Controls.Add(this.btnEdit);
			base.Controls.Add(this.btnCreate);
			base.Controls.Add(this.btnSearch);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.dgvProduct);
			base.Controls.Add(this.label1);
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.Name = "frmBookTemHum1";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "SỔ THEO DÕI NHIỆT ĐỘ - ĐỘ ẨM";
			base.WindowState = FormWindowState.Maximized;
			base.Load += new EventHandler(this.frmInput_Load);
			base.KeyDown += new KeyEventHandler(this.frmInput_KeyDown);
			((ISupportInitialize)this.dgvProduct).EndInit();
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmBookTemHum1()
		{
			this.InitializeComponent();
			this.sqlCon = this.objFunc.strConnectionString;
		}
		private void frmInput_Load(object sender, EventArgs e)
		{
			this.dgvProduct.AutoGenerateColumns = false;
			this.getTempConfig();
			this.btnSearch.PerformClick();
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void frmInput_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.F5)
			{
				this.btnEdit.PerformClick();
			}
			else
			{
				if (e.KeyCode == Keys.F6)
				{
					this.btnCreate.PerformClick();
				}
				else
				{
					if (e.KeyCode == Keys.F7)
					{
						this.btnPrint.PerformClick();
					}
					else
					{
						if (e.KeyCode == Keys.Escape)
						{
							base.Close();
						}
					}
				}
			}
		}
		public void getInfomation(string sqlQuery)
		{
			try
			{
				DataTable dataTable = new DataTable();
				DataColumn column = new DataColumn("Day", typeof(string));
				DataColumn column2 = new DataColumn("Tmp1", typeof(string));
				DataColumn column3 = new DataColumn("Tmp2", typeof(string));
				DataColumn column4 = new DataColumn("Hum1", typeof(string));
				DataColumn column5 = new DataColumn("Hum2", typeof(string));
				DataColumn column6 = new DataColumn("PersonAction", typeof(string));
				DataColumn column7 = new DataColumn("PersonCheck", typeof(string));
				DataColumn column8 = new DataColumn("Note", typeof(string));
				dataTable.Columns.Add(column);
				dataTable.Columns.Add(column2);
				dataTable.Columns.Add(column3);
				dataTable.Columns.Add(column4);
				dataTable.Columns.Add(column5);
				dataTable.Columns.Add(column6);
				dataTable.Columns.Add(column7);
				dataTable.Columns.Add(column8);
				SqlConnection sqlConnection = new SqlConnection(this.sqlCon);
				sqlConnection.Open();
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.CommandText = "SELECT * FROM [TabTemperature] WHERE [Month] = " + this.txtfromDay.Value.Month.ToString() + " AND [Year] = " + this.txtfromDay.Value.Year.ToString();
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				while (sqlDataReader.Read())
				{
					dataTable.Rows.Add(new object[]
					{
						sqlDataReader["Day"].ToString(),
						sqlDataReader["Tmp1"].ToString(),
						sqlDataReader["Tmp2"].ToString(),
						sqlDataReader["Hum1"].ToString(),
						sqlDataReader["Hum2"].ToString(),
						sqlDataReader["PersonAction"].ToString(),
						sqlDataReader["PersonCheck"].ToString(),
						sqlDataReader["Note"].ToString()
					});
				}
				sqlDataReader.Close();
				sqlConnection.Close();
				sqlConnection.Dispose();
				this.objTable = dataTable;
				this.dgvProduct.DataSource = this.objTable;
			}
			catch (Exception ex)
			{
				MessageBox.Show("1 : " + ex.Message);
				this.objTable = null;
				this.dgvProduct.DataSource = this.objTable;
			}
		}
		private void btnSearch_Click(object sender, EventArgs e)
		{
			try
			{
				this.getInfomation("");
				if (this.objTable.Rows.Count == 0)
				{
					if (MessageBox.Show("Bạn có muốn khởi tạo số liệu cho tháng hiện tại không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
					{
						SqlConnection sqlConnection = new SqlConnection(this.sqlCon);
						sqlConnection.Open();
						SqlCommand sqlCommand = sqlConnection.CreateCommand();
						for (int i = 1; i <= this.getDaysInMonth(this.txtfromDay.Value.Month, this.txtfromDay.Value.Year); i++)
						{
							sqlCommand.CommandText = string.Concat(new string[]
							{
								"INSERT INTO [TabTemperature](Day,Month,Year,Tmp1,Hum1,Tmp2,Hum2,Tmp3,Hum3,Tmp4,Hum4,Note) VALUES(",
								i.ToString(),
								",",
								this.txtfromDay.Value.Month.ToString(),
								",",
								this.txtfromDay.Value.Year.ToString(),
								",' - ',' - ',' - ',' - ',' - ',' - ',' - ',' - ',' - ')"
							});
							sqlCommand.ExecuteNonQuery();
						}
						sqlConnection.Close();
						sqlConnection.Dispose();
					}
					this.getInfomation("");
				}
			}
			catch
			{
			}
		}
		private void resetDataGridView()
		{
			this.objTable = null;
			this.dgvProduct.DataSource = this.objTable;
		}
		private void btnCreate_Click(object sender, EventArgs e)
		{
			for (int i = 0; i < this.dgvProduct.Rows.Count; i++)
			{
				this.updateInformation(this.dgvProduct.Rows[i].Cells["Day"].Value.ToString(), this.dgvProduct.Rows[i].Cells["Tmp1"].Value.ToString(), this.dgvProduct.Rows[i].Cells["Hum1"].Value.ToString(), this.dgvProduct.Rows[i].Cells["Tmp2"].Value.ToString(), this.dgvProduct.Rows[i].Cells["Hum2"].Value.ToString(), this.dgvProduct.Rows[i].Cells["PersonAction"].Value.ToString(), this.dgvProduct.Rows[i].Cells["PersonCheck"].Value.ToString(), this.dgvProduct.Rows[i].Cells["Note"].Value.ToString());
			}
			this.btnCreate.Enabled = false;
			this.btnEdit.Enabled = true;
			this.dgvProduct.ReadOnly = true;
			this.dgvProduct.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
		}
		public void updateInformation(string DayNow, string Tmp1, string Hum1, string Tmp2, string Hum2, string PersonAction, string PersonCheck, string Note)
		{
			try
			{
				SqlConnection sqlConnection = new SqlConnection(this.sqlCon);
				sqlConnection.Open();
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.CommandText = string.Concat(new string[]
				{
					"UPDATE [TabTemperature] SET [Tmp1] = '",
					Tmp1,
					"', [Hum1] = '",
					Hum1,
					"', [Tmp2] = '",
					Tmp2,
					"', [Hum2] = '",
					Hum2,
					"', [PersonCheck] = '",
					PersonCheck,
					"', [PersonAction] = '",
					PersonAction,
					"', [Note] = N'",
					Note,
					"' WHERE [Day] = ",
					DayNow,
					" AND [Month] = ",
					this.txtfromDay.Value.Month.ToString(),
					" AND [Year] = ",
					this.txtfromDay.Value.Year.ToString()
				});
				sqlCommand.ExecuteNonQuery();
				sqlConnection.Close();
				sqlConnection.Dispose();
			}
			catch
			{
			}
		}
		private void btnEdit_Click(object sender, EventArgs e)
		{
			this.btnCreate.Enabled = true;
			this.btnEdit.Enabled = false;
			this.dgvProduct.ReadOnly = false;
			this.dgvProduct.SelectionMode = DataGridViewSelectionMode.CellSelect;
		}
		public int getDaysInMonth(int month, int year)
		{
			if (month < 1 || month > 12)
			{
				throw new ArgumentOutOfRangeException("month", month, "month must be between 1 and 12");
			}
			int result;
			if (1 == month || 3 == month || 5 == month || 7 == month || 8 == month || 10 == month || 12 == month)
			{
				result = 31;
			}
			else
			{
				if (2 == month)
				{
					if (0 == year % 4)
					{
						if (0 == year % 400)
						{
							result = 29;
						}
						else
						{
							if (0 == year % 100)
							{
								result = 28;
							}
							else
							{
								result = 29;
							}
						}
					}
					else
					{
						result = 28;
					}
				}
				else
				{
					result = 30;
				}
			}
			return result;
		}
		private void btnPrint_Click(object sender, EventArgs e)
		{
			frmBookSellNotBillView frmBookSellNotBillView = new frmBookSellNotBillView();
			frmBookSellNotBillView.objectName = "BookTemHum1Print";
			frmBookTemHum1Print.objTable = this.objTable;
			frmBookTemHum1Print.datePrint = "Tháng " + this.txtfromDay.Value.Month.ToString() + " năm " + this.txtfromDay.Value.Year.ToString();
			frmBookSellNotBillView.ShowDialog();
		}
		private void btnExportToExcel_Click(object sender, EventArgs e)
		{
			try
			{
				frmBookTemHum1Print.objTable = new DataTable();
				frmBookTemHum1Print.objTable = this.objTable;
				ActiveReport3 activeReport = new frmBookTemHum1Print();
				activeReport.Run();
				XlsExport xlsExport = new XlsExport();
				SaveFileDialog saveFileDialog = new SaveFileDialog();
				saveFileDialog.ShowDialog();
				string text = saveFileDialog.FileName;
				if (text != "")
				{
					if (!text.ToUpper().Contains(".XLS"))
					{
						text += ".xls";
					}
					xlsExport.Export(activeReport.Document, text);
					MessageBox.Show("Hệ thống đã hoàn thành việc xuất dữ liệu ra file Excel", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show("Bạn chưa chọn đường dẫn và tên file cần xuất!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				}
			}
			catch
			{
			}
		}
		private void btnConfig_Click(object sender, EventArgs e)
		{
			frmConfigTempHum frmConfigTempHum = new frmConfigTempHum();
			frmConfigTempHum.ShowDialog();
			this.getTempConfig();
		}
		private void getTempConfig()
		{
			try
			{
				SqlConnection sqlConnection = new SqlConnection(this.objFunc.strConnectionString);
				sqlConnection.Open();
				SqlCommand sqlCommand = sqlConnection.CreateCommand();
				sqlCommand.CommandText = "SELECT TOP 1 * FROM [TabConfigTempHum]";
				SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
				while (sqlDataReader.Read())
				{
					this.label9.Text = sqlDataReader["T1"].ToString();
					this.label10.Text = sqlDataReader["T2"].ToString();
					this.label12.Text = sqlDataReader["T1"].ToString();
					this.label11.Text = sqlDataReader["T2"].ToString();
				}
				sqlDataReader.Close();
				sqlConnection.Close();
				sqlConnection.Dispose();
			}
			catch
			{
				this.lblT1.Text = "9 Giờ";
				this.lblT2.Text = "11 Giờ 30";
				this.lblT3.Text = "14 Giờ";
				this.lblT4.Text = "17 Giờ";
			}
		}
		private void txtfromDay_ValueChanged(object sender, EventArgs e)
		{
			this.btnSearch.PerformClick();
		}
	}
}
